package edu.ccut.saturn.studio.dialog.logicdialog;

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.widgets.Shell;

import edu.ccut.saturn.studio.dialog.ParentPrimaryDialog;
import edu.ccut.saturn.studio.logic.model.saturn.SaturnLogicNode;
import edu.ccut.saturn.studio.util.ConversionUtil;

public class SaturnLogicDialog extends ParentPrimaryDialog {

	private SaturnLogicNode saturnLogicNode;
	
	public SaturnLogicDialog(Shell parentShell, SaturnLogicNode saturnLogic){
		super(parentShell,saturnLogic);
		this.saturnLogicNode = saturnLogic;
	}
	
	protected void initialization() {
		super.expressionText.setText(saturnLogicNode.getKey().trim());
		super.tableViewer.setInput(ConversionUtil.scopeMapFromXmlToSurface(super.parameterlist));
	}
	
	protected void buttonPressed(int buttonId) {
		if (parameterlist == null) {
			return;
		}
		if (buttonId == IDialogConstants.OK_ID) {
			shape.setDescription(super.descriptionText.getText().trim());
			saturnLogicNode.setKey(super.expressionText.getText().trim());
			ConversionUtil.scopeMap(super.parameterlist);
			shape.setParameters(super.parameterlist);	//问题出现在这里
			shape.setName(super.nameText.getText().trim());
		}
		super.buttonPressed(buttonId);
	}
}
